<div class="content-wrapper">

    <section class="content-header">
        <?=$this->partial('layout/breadcrumb')?>

        <h1 class="pull-right">
            <a href="<?=$this->url('goods', ['action'=> 'add']);?>" class="btn btn-primary btn-sm"><i class="fa fa-plus"></i> <?=$this->translate('添加商品')?></a>
            <?=$this->HelpUrl('goodsList')?>
        </h1>

    </section>

    <section class="content">
        <?=$this->partial('layout/messages'); ?>

        <div class="row">
            <div class="col-xs-12">
                <div class="box erp-box">
                    <div class="box-body table-responsive no-padding">
                            <table class="table table-hover">
                                <thead>
                                <tr class="erp-bg-thead">
                                    <th width="6%">ID</th>
                                    <th width="20%"><?=$this->translate('商品名称')?></th>
                                    <th width="10%"><?=$this->translate('商品编号')?></th>
                                    <th width="12%"><?=$this->translate('商品规格')?></th>
                                    <th width="10%"><?=$this->translate('采购价格')?></th>
                                    <th width="7%"><?=$this->translate('建议售价')?></th>
                                    <th width="10%"><?=$this->translate('商品分类')?></th>
                                    <th width="8%"><?=$this->translate('商品品牌')?></th>
                                    <th width="6%"><?=$this->translate('库存')?></th>
                                    <th width="12%"><?=$this->translate('操作')?></th>
                                </tr>
                                <?php
                                $sForm = $this->searchForm;
                                $sForm->prepare();
                                ?>
                                <?= $this->form()->openTag($sForm); ?>
                                <tr>
                                    <td>
                                        <p>
                                            <?= $this->formElement($sForm->get('start_id')); ?>
                                        </p>
                                        <div>
                                            <?= $this->formElement($sForm->get('end_id')); ?>
                                        </div>
                                        <?=$this->formElementErrors($sForm->get('start_id'), ['class'=>'error-message']);?>
                                        <?=$this->formElementErrors($sForm->get('end_id'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <?= $this->formElement($sForm->get('goods_name')); ?>
                                        <?=$this->formElementErrors($sForm->get('goods_name'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <?= $this->formElement($sForm->get('goods_number')); ?>
                                        <?=$this->formElementErrors($sForm->get('goods_number'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <?= $this->formElement($sForm->get('goods_spec')); ?>
                                        <?=$this->formElementErrors($sForm->get('goods_spec'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <p>
                                            <?= $this->formElement($sForm->get('start_price')); ?>
                                        </p>
                                        <div>
                                            <?= $this->formElement($sForm->get('end_price')); ?>
                                        </div>
                                        <?=$this->formElementErrors($sForm->get('start_price'), ['class'=>'error-message']);?>
                                        <?=$this->formElementErrors($sForm->get('end_price'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <p>
                                            <?= $this->formElement($sForm->get('start_sales_price')); ?>
                                        </p>
                                        <div>
                                            <?= $this->formElement($sForm->get('end_sales_price')); ?>
                                        </div>
                                        <?=$this->formElementErrors($sForm->get('start_sales_price'), ['class'=>'error-message']);?>
                                        <?=$this->formElementErrors($sForm->get('end_sales_price'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <?= $this->formElement($sForm->get('goods_category_id')); ?>
                                        <?=$this->formElementErrors($sForm->get('goods_category_id'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <?= $this->formElement($sForm->get('brand_id')); ?>
                                        <?=$this->formElementErrors($sForm->get('brand_id'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <p>
                                            <?= $this->formElement($sForm->get('start_stock')); ?>
                                        </p>
                                        <div>
                                            <?= $this->formElement($sForm->get('end_stock')); ?>
                                        </div>
                                        <?=$this->formElementErrors($sForm->get('start_stock'), ['class'=>'error-message']);?>
                                        <?=$this->formElementErrors($sForm->get('end_stock'), ['class'=>'error-message']);?>
                                    </td>
                                    <td>
                                        <button type="submit" class="btn btn-info btn-sm"><i class="fa fa-search"></i></button>
                                        <?php if(!empty(array_filter($sForm->getData()))) { ?>
                                            <a href="<?=$this->url('goods');?>" class="btn btn-default btn-sm"><i class="fa fa-reply"></i></a>
                                        <?php } ?>
                                    </td>
                                </tr>
                                <?= $this->form()->closeTag(); ?>
                                </thead>

                                <?php if($this->goodsList) foreach ($this->goodsList as $goods) { ?>
                                    <tr>
                                        <td><?=$goods->getGoodsId()?></td>
                                        <td><?=$this->escapeHtml($goods->getGoodsName())?></td>
                                        <td><?= $this->escapeHtml($goods->getGoodsNumber())?></td>
                                        <td><?= empty($goods->getGoodsSpec()) ? $this->translate('无') : $this->escapeHtml($goods->getGoodsSpec())?></td>
                                        <td>
                                            <?php if ($goods->getGoodsPrice() > 0) { ?>
                                            <?=$this->erpCurrencyFormat($goods->getGoodsPrice())?> <a href="<?=$this->url('goods', ['action' => 'priceTrend', 'id' => $goods->getGoodsId()]);?>" title="<?=$this->translate('价格走势')?>"><i class="fa fa-bar-chart text-green"></i></a></td>
                                            <?php } else echo $this->translate('无'); ?>
                                        <td><?=$this->erpCurrencyFormat($goods->getGoodsRecommendPrice())?></td>
                                        <td><?= $this->escapeHtml($goods->getGoodsCategory()->getGoodsCategoryName())?></td>
                                        <td><?= empty($goods->getBrand()) ? $this->translate('无') : $this->escapeHtml($goods->getBrand()->getBrandName())?></td>
                                        <td>
                                            <?php if($goods->getGoodsStock() > 0) { ?>
                                                <?=$goods->getGoodsStock()?> <a href="<?=$this->url('goods', ['action' => 'goodsWarehouse', 'id' => $goods->getGoodsId()]);?>" title="<?=$this->translate('仓库分布')?>"><i class="fa fa-cubes text-green"></i></a>
                                            <?php } else { ?>
                                                <?=$this->translate('无')?>
                                            <?php } ?>
                                        </td>
                                        <td>
                                            <a href="<?= $this->url('goods',
                                                ['action'=>'edit', 'id'=>$goods->getGoodsId()]); ?>"
                                               class="btn btn-xs btn-success"><i class="fa fa-pencil"></i> <?=$this->translate('编辑')?>
                                            </a>

                                            <a href="javascript:;" onclick="deleteConfirm('<?=$this->translate('您确实要删除该商品吗？')?>', '<?= $this->url('goods', ['action'=>'delete', 'id'=>$goods->getGoodsId()], ['query' => ['qToken' => $this->adminHelper()->getCsrfValue()]]); ?>');" class="btn btn-xs btn-danger">
                                                <i class="fa fa-trash"></i> <?=$this->translate('删除')?>
                                            </a>

                                        </td>
                                    </tr>
                                <?php } ?>
                            </table>
                    </div>
                    <div class="box-footer clearfix">
                        <?=$this->paginationControl($this->goodsList,
                            'Sliding',
                            'layout/page',
                            ['route' => 'goods']); ?>
                    </div>
                </div>

            </div>
        </div>

    </section>
</div>